package com.example.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.domain.AreaEntity;
import com.example.mapper.AreaMapper;
import com.example.service.AreaService;

@Service
@Transactional
public class AreaServiceImp implements AreaService {

	@Autowired
	AreaMapper areaMapper;

	
	@Override
	public List<AreaEntity> queryProvinceData(String longitude, String latitude) {
		QueryWrapper<AreaEntity> wrapper = new QueryWrapper<AreaEntity>();
		wrapper.lt("longitude1", longitude);
		wrapper.gt("longitude2", longitude);
		wrapper.lt("latitude1", latitude);
		wrapper.gt("latitude2", latitude);
		wrapper.eq("level", "province");
		return areaMapper.selectList(wrapper);
	}

	@Override
	public List<AreaEntity> queryCityData(String longitude, String latitude) {
		QueryWrapper<AreaEntity> wrapper = new QueryWrapper<AreaEntity>();
		wrapper.lt("longitude1", longitude);
		wrapper.gt("longitude2", longitude);
		wrapper.lt("latitude1", latitude);
		wrapper.gt("latitude2", latitude);
		wrapper.isNull("level");
		return areaMapper.selectList(wrapper);
	}
	
	public static void main(String[] args) {
		String qiBie = "2021-08-27";
		String[] temp = qiBie.split("-");
		System.out.println(Integer.valueOf(temp[1]).intValue());
		if(Integer.valueOf(temp[1]).intValue()<0) {
			qiBie = temp[0] + "-0" + Integer.valueOf(temp[1]).intValue();
		}else {
			qiBie = temp[0] + "-" + Integer.valueOf(temp[1]).intValue();
		}
	}
}

